﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

public partial class middle : System.Web.UI.Page
{
    UserHelper u = new UserHelper();
    protected int Num = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            Num = Convert.ToInt32(Request.QueryString["ID"]);
        }
        catch
        {
            Response.Write("<script language='javascript'>window.location='About/error.html'</script>");
        }
        if (Num <= 5 && Num > 0)
        {
            Literal title = Master.FindControl("title") as Literal;
            title.Text = "宣汉知名律师-宣汉律师-秦锐-" + GetClass();
            if (!IsPostBack)
            {
                AspNetPager1.RecordCount = u.GetTopicCount(Num);
                bindData();

            }
        }
        else
        {
            Response.Write("<script language='javascript'>window.location='About/error.html'</script>");
            Num = 0;
        }
    }
    public void bindData()
    {
        Repeater1.DataSource = u.GetTopicListInfo(AspNetPager1.StartRecordIndex, AspNetPager1.EndRecordIndex, Num);
        Repeater1.DataBind();
    }
    public string GetClass()
    {
        return u.GetTopicClass(Num);
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        bindData();
    }
    protected string info(string a)
    {
        int b = Convert.ToInt32(a);
        return u.GetTopicClass(b);

    }
    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Literal li = (Literal)e.Item.FindControl("textClass");
            li.Text =u.GetTopicClass(Convert.ToInt32(li.Text));
        }
    }
    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
    }
}